function  Formsubmit(Form) {

	if(Form.id == "ExportProductForm"){
		var ClothingProductID_List = document.getElementById("ClothingProductID_List").value;
		var ShoesProductID_List = document.getElementById("ShoesProductID_List").value;
		if(ClothingProductID_List == "" && ShoesProductID_List == ""){
			alert("请选择要导出的商品。");
			return false;
		}

		if((ClothingProductID_List != "" && ShoesProductID_List != "")){
			alert("只能选择一种分类产品。");
			return false;
			
		}
	}

	

    setTimeout(function () {
        Form.submit();
        return true;
    }, 100);
}

function SelectAllShoes(InputObj) {
    var InputElements = $("input[type=checkbox][id^=Shoes_]");
    var myChecked = InputObj.checked;

    if (InputElements.length > 0) {
        for (var i = 0; i < InputElements.length; i++) {
            InputElements[i].checked = myChecked;
			ShoesProduct_Toggle(InputElements[i]);
        }
    }
}

function SelectAllClothing(InputObj) {
    var InputElements = $("input[type=checkbox][id^=Clothing_]");
    var myChecked = InputObj.checked;

    if (InputElements.length > 0) {
        for (var i = 0; i < InputElements.length; i++) {
            InputElements[i].checked = myChecked;
			ClothingProduct_Toggle(InputElements[i]);
        }
    }
}


function ClothingProduct_Toggle(InputObj) {
    var myList = document.getElementById("ClothingProductID_List").value;

    if (myList == "") {
        myList = "|";
    }

    var ProductID = InputObj.value;
    var startIndex = myList.indexOf("|" + ProductID + "|");

    if (startIndex < 0 && InputObj.checked) {
        myList += ProductID + "|";
    } else if (startIndex >= 0 && !InputObj.checked) {
        ++startIndex;
        myList = myList.substr(0, startIndex) + myList.substr(startIndex + ProductID.length + 1, myList.length);
    }

    if (myList == "|") {
        myList = "";
    }

    document.getElementById("ClothingProductID_List").value = myList;
}


function ShoesProduct_Toggle(InputObj) {
    var myList = document.getElementById("ShoesProductID_List").value;

    if (myList == "") {
        myList = "|";
    }

    var ProductID = InputObj.value;
    var startIndex = myList.indexOf("|" + ProductID + "|");

    if (startIndex < 0 && InputObj.checked) {
        myList += ProductID + "|";
    } else if (startIndex >= 0 && !InputObj.checked) {
        ++startIndex;
        myList = myList.substr(0, startIndex) + myList.substr(startIndex + ProductID.length + 1, myList.length);
    }

    if (myList == "|") {
        myList = "";
    }

    document.getElementById("ShoesProductID_List").value = myList;
}

function AutoImport(TemplateType, ProductID){
//SaveImportSheet/AutoImport

	var AjaxURl = BaseUrl + "/SaveImportSheet/AutoImport";

	
	if(TemplateType == "Shoes"){ 
		AjaxURl += "/ShoesProductID_List/"+ProductID;
	}
	else if(TemplateType == "Clothing"){
		AjaxURl += "/ClothingProductID_List/"+ProductID;
	}

	$.get(AjaxURl, function(result){
		$.get("/MarketplaceWebService/Samples/SubmitFeedSample.php?FileName=" + result, function(result){
			alert(result);
		});
	});
}